package com.ruoyi.common.utils;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;

import java.nio.charset.Charset;

public class StrConverter {
    public static ByteBuf getByteBuf(String cotent, ChannelHandlerContext channelHandlerContext) {
        byte[] bs = cotent.getBytes(Charset.forName("utf-8"));
        ByteBuf byteBuf = channelHandlerContext.alloc().buffer();
        byteBuf.writeBytes(bs);
        return byteBuf;
    }
    public static String getStr(ByteBuf cotent) {
        return cotent.toString(Charset.forName("utf-8"));
    }
}
